package switchviz.gui;
import java.awt.BorderLayout;
import java.awt.event.KeyEvent;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.apache.log4j.Logger;

import switchviz.Application;
import switchviz.core.alias.AliasPanel;
import switchviz.core.mib.MIBPanel;


public class ConfigurationPanel extends JPanel implements ChangeListener
{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 6709591058968420799L;
	private static Logger logger = Logger.getLogger(ConfigurationPanel.class);
	private JTabbedPane _tabbedPane;
	
	public ConfigurationPanel()
	{
		if (logger.isInfoEnabled()) { logger.info("Initialize ..."); }
		this.initialize();
	}

	private JTabbedPane getTabbedPane()
	{
		if (_tabbedPane == null)
		{
			_tabbedPane = new JTabbedPane();
			_tabbedPane.addTab("Alias", new AliasPanel());
			_tabbedPane.addTab("MIB Browser", new MIBPanel());
			_tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
			_tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
			_tabbedPane.addChangeListener(this);
		}
		return _tabbedPane;
	}
	
	private void initialize()
	{
		this.setLayout(new BorderLayout());
		this.add(getTabbedPane(), BorderLayout.CENTER);
	}

	public void stateChanged(ChangeEvent evt)
	{
		int index = _tabbedPane.getSelectedIndex();
		switch(index)
		{
		case 0:
			Application.getInstance().getMainFrame().getMainPanel().getStatusBar().setText("Alias Browser");
			break;
		case 1:
			Application.getInstance().getMainFrame().getMainPanel().getStatusBar().setText("MIB Manager");
			break;
		}
	}
	
	
}
